In [1]:
# When using ipython this will import matplotlib to plt and numpy to np
# As a quick replacement the following three lines can be replaced by %pylab inline
import numpy as np
import matplotlib.pyplot as plt

# This is so that plots are shown inline within this  notebook
%matplotlib inline

# The interp1d function imported here allows for 1d interpolation 
# Documentation and examples: 
#    http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
from scipy.interpolate import interp1d

# This is the interactive plotting module
import bokeh.plotting as bkh
# This bokeh function makes interactive plots be drawn inline into the notebook
bkh.output_notebook()

# This looks in pymephisto/__init__.py for the function load_mephisto 
# which is set up to include the functions that will need to be called
from pymephisto import load_mephisto

# Install this package by running the bat file at:
#   S:\Python Packages\run_install_all.bat
from pddprofile import normalise, bokeh_display


BokehJS successfully loaded.

In [2]:
# Can change csv output directory with 
# load_mephisto('06MeV06x06.mcc', output_directory='example')
distance, relative_dose, scan_curvetype, scan_depth = load_mephisto(
    '6MV 15x15 Wedge.mcc')
bokeh_display(distance, relative_dose)



In [4]:
# To normalise the scans use the normalise function found within the pddprofiles module
relative_dose = normalise(
    distance, relative_dose, scan_curvetype, scan_depth,
    profile_normalisation_position='cra')
bokeh_display(distance, relative_dose)



In [5]:
# There are many options for normalisation
relative_dose = normalise(
    distance, relative_dose, scan_curvetype, scan_depth,
    pdd_normalisation_depth=100,
    profile_normalisation_position='cra', scale_to_pdd=True)
bokeh_display(distance, relative_dose)



In [5]:
# Each element in scan_curvetype array refers to a scan in the mephisto file
scan_curvetype


Out[5]:
array(['INPLANE_PROFILE', 'INPLANE_PROFILE', 'INPLANE_PROFILE',
       'INPLANE_PROFILE', 'PDD', 'CROSSPLANE_PROFILE',
       'CROSSPLANE_PROFILE', 'CROSSPLANE_PROFILE', 'CROSSPLANE_PROFILE'], 
      dtype='<U18')

In [6]:
# nan means "not a number", used for pdds (scan depth is irrelevant for pdd)
scan_depth


Out[6]:
array([  13.,   50.,  100.,  200.,   nan,   13.,   50.,  100.,  200.])

In [7]:
scan_curvetype[3] # This references the "4th" element as 0 is the 1st element


Out[7]:
'INPLANE_PROFILE'

In [8]:
scan_depth[3]


Out[8]:
200.0

In [9]:
distance # Distance is a list of arrays all found within the file given


Out[9]:
[array([-173.47, -168.9 , -164.34, -159.77, -155.21, -150.65, -146.08,
        -141.51, -136.95, -132.38, -127.82, -123.25, -118.69, -114.13,
        -109.56, -104.99, -100.43,  -95.86,  -91.3 ,  -86.74,  -82.17,
         -81.26,  -80.34,  -79.43,  -78.52,  -77.6 ,  -76.69,  -75.78,
         -74.87,  -73.95,  -73.04,  -72.13,  -71.21,  -70.3 ,  -69.39,
         -68.47,  -67.56,  -66.65,  -65.74,  -64.82,  -63.91,  -63.  ,
         -62.08,  -61.17,  -60.26,  -59.34,  -58.43,  -57.52,  -56.61,
         -55.69,  -54.78,  -53.87,  -52.95,  -52.04,  -51.13,  -50.22,
         -48.39,  -46.56,  -44.74,  -42.91,  -41.08,  -39.26,  -37.43,
         -35.61,  -33.78,  -31.95,  -30.13,  -28.3 ,  -26.48,  -24.65,
         -22.82,  -21.  ,  -19.17,  -17.35,  -15.52,  -13.69,  -11.87,
         -10.04,   -8.22,   -6.39,   -4.57,   -2.74,   -0.91,    0.  ,
           0.91,    2.74,    4.57,    6.39,    8.22,   10.04,   11.87,
          13.69,   15.52,   17.35,   19.17,   21.  ,   22.82,   24.65,
          26.48,   28.3 ,   30.13,   31.95,   33.78,   35.61,   37.43,
          39.26,   41.08,   42.91,   44.74,   46.56,   48.39,   50.22,
          51.13,   52.04,   52.95,   53.87,   54.78,   55.69,   56.61,
          57.52,   58.43,   59.34,   60.26,   61.17,   62.08,   63.  ,
          63.91,   64.82,   65.74,   66.65,   67.56,   68.47,   69.39,
          70.3 ,   71.21,   72.13,   73.04,   73.95,   74.87,   75.78,
          76.69,   77.6 ,   78.52,   79.43,   80.34,   81.26,   82.17,
          86.74,   91.3 ,   95.86,  100.43,  104.99,  109.56,  114.13,
         118.69,  123.25,  127.82,  132.38,  136.95,  141.51,  146.08,
         150.65,  155.21,  159.77,  164.34,  168.9 ,  173.47]),
 array([-180.5 , -175.75, -171.  , -166.25, -161.5 , -156.75, -152.  ,
        -147.25, -142.5 , -137.75, -133.  , -128.25, -123.5 , -118.75,
        -114.  , -109.25, -104.5 ,  -99.75,  -95.  ,  -90.25,  -85.5 ,
         -84.55,  -83.6 ,  -82.65,  -81.7 ,  -80.75,  -79.8 ,  -78.85,
         -77.9 ,  -76.95,  -76.  ,  -75.05,  -74.1 ,  -73.15,  -72.2 ,
         -71.25,  -70.3 ,  -69.35,  -68.4 ,  -67.45,  -66.5 ,  -65.55,
         -64.6 ,  -63.65,  -62.7 ,  -61.75,  -60.8 ,  -59.85,  -58.9 ,
         -57.95,  -57.  ,  -56.05,  -55.1 ,  -54.15,  -53.2 ,  -52.25,
         -50.35,  -48.45,  -46.55,  -44.65,  -42.75,  -40.85,  -38.95,
         -37.05,  -35.15,  -33.25,  -31.35,  -29.45,  -27.55,  -25.65,
         -23.75,  -21.85,  -19.95,  -18.05,  -16.15,  -14.25,  -12.35,
         -10.45,   -8.55,   -6.65,   -4.75,   -2.85,   -0.95,    0.  ,
           0.95,    2.85,    4.75,    6.65,    8.55,   10.45,   12.35,
          14.25,   16.15,   18.05,   19.95,   21.85,   23.75,   25.65,
          27.55,   29.45,   31.35,   33.25,   35.15,   37.05,   38.95,
          40.85,   42.75,   44.65,   46.55,   48.45,   50.35,   52.25,
          53.2 ,   54.15,   55.1 ,   56.05,   57.  ,   57.95,   58.9 ,
          59.85,   60.8 ,   61.75,   62.7 ,   63.65,   64.6 ,   65.55,
          66.5 ,   67.45,   68.4 ,   69.35,   70.3 ,   71.25,   72.2 ,
          73.15,   74.1 ,   75.05,   76.  ,   76.95,   77.9 ,   78.85,
          79.8 ,   80.75,   81.7 ,   82.65,   83.6 ,   84.55,   85.5 ,
          90.25,   95.  ,   99.75,  104.5 ,  109.25,  114.  ,  118.75,
         123.5 ,  128.25,  133.  ,  137.75,  142.5 ,  147.25,  152.  ,
         156.75,  161.5 ,  166.25,  171.  ,  175.75,  180.5 ]),
 array([-190., -185., -180., -175., -170., -165., -160., -155., -150.,
        -145., -140., -135., -130., -125., -120., -115., -110., -105.,
        -100.,  -95.,  -90.,  -89.,  -88.,  -87.,  -86.,  -85.,  -84.,
         -83.,  -82.,  -81.,  -80.,  -79.,  -78.,  -77.,  -76.,  -75.,
         -74.,  -73.,  -72.,  -71.,  -70.,  -69.,  -68.,  -67.,  -66.,
         -65.,  -64.,  -63.,  -62.,  -61.,  -60.,  -59.,  -58.,  -57.,
         -56.,  -55.,  -53.,  -51.,  -49.,  -47.,  -45.,  -43.,  -41.,
         -39.,  -37.,  -35.,  -33.,  -31.,  -29.,  -27.,  -25.,  -23.,
         -21.,  -19.,  -17.,  -15.,  -13.,  -11.,   -9.,   -7.,   -5.,
          -3.,   -1.,    0.,    1.,    3.,    5.,    7.,    9.,   11.,
          13.,   15.,   17.,   19.,   21.,   23.,   25.,   27.,   29.,
          31.,   33.,   35.,   37.,   39.,   41.,   43.,   45.,   47.,
          49.,   51.,   53.,   55.,   56.,   57.,   58.,   59.,   60.,
          61.,   62.,   63.,   64.,   65.,   66.,   67.,   68.,   69.,
          70.,   71.,   72.,   73.,   74.,   75.,   76.,   77.,   78.,
          79.,   80.,   81.,   82.,   83.,   84.,   85.,   86.,   87.,
          88.,   89.,   90.,   95.,  100.,  105.,  110.,  115.,  120.,
         125.,  130.,  135.,  140.,  145.,  150.,  155.,  160.,  165.,
         170.,  175.,  180.,  185.,  190.]),
 array([-209. , -203.5, -198. , -192.5, -187. , -181.5, -176. , -170.5,
        -165. , -159.5, -154. , -148.5, -143. , -137.5, -132. , -126.5,
        -121. , -115.5, -110. , -104.5,  -99. ,  -97.9,  -96.8,  -95.7,
         -94.6,  -93.5,  -92.4,  -91.3,  -90.2,  -89.1,  -88. ,  -86.9,
         -85.8,  -84.7,  -83.6,  -82.5,  -81.4,  -80.3,  -79.2,  -78.1,
         -77. ,  -75.9,  -74.8,  -73.7,  -72.6,  -71.5,  -70.4,  -69.3,
         -68.2,  -67.1,  -66. ,  -64.9,  -63.8,  -62.7,  -61.6,  -60.5,
         -58.3,  -56.1,  -53.9,  -51.7,  -49.5,  -47.3,  -45.1,  -42.9,
         -40.7,  -38.5,  -36.3,  -34.1,  -31.9,  -29.7,  -27.5,  -25.3,
         -23.1,  -20.9,  -18.7,  -16.5,  -14.3,  -12.1,   -9.9,   -7.7,
          -5.5,   -3.3,   -1.1,    0. ,    1.1,    3.3,    5.5,    7.7,
           9.9,   12.1,   14.3,   16.5,   18.7,   20.9,   23.1,   25.3,
          27.5,   29.7,   31.9,   34.1,   36.3,   38.5,   40.7,   42.9,
          45.1,   47.3,   49.5,   51.7,   53.9,   56.1,   58.3,   60.5,
          61.6,   62.7,   63.8,   64.9,   66. ,   67.1,   68.2,   69.3,
          70.4,   71.5,   72.6,   73.7,   74.8,   75.9,   77. ,   78.1,
          79.2,   80.3,   81.4,   82.5,   83.6,   84.7,   85.8,   86.9,
          88. ,   89.1,   90.2,   91.3,   92.4,   93.5,   94.6,   95.7,
          96.8,   97.9,   99. ,  104.5,  110. ,  115.5,  121. ,  126.5,
         132. ,  137.5,  143. ,  148.5,  154. ,  159.5,  165. ,  170.5,
         176. ,  181.5,  187. ,  192.5,  198. ,  203.5,  209. ]),
 array([   0. ,    1. ,    2. ,    3. ,    4. ,    5. ,    6. ,    7. ,
           8. ,    9. ,   10. ,   11. ,   12. ,   13. ,   14. ,   15. ,
          16. ,   17. ,   18. ,   19. ,   20. ,   21. ,   22. ,   23. ,
          24. ,   25. ,   26. ,   27. ,   28. ,   29. ,   30. ,   31. ,
          32. ,   33. ,   34. ,   35. ,   36. ,   37. ,   38. ,   39. ,
          40. ,   42.5,   45. ,   47.5,   50. ,   52.5,   55. ,   57.5,
          60. ,   65. ,   70. ,   75. ,   80. ,   85. ,   90. ,   95. ,
         100. ,  105. ,  110. ,  115. ,  120. ,  125. ,  130. ,  135. ,
         140. ,  145. ,  150. ,  155. ,  160. ,  165. ,  170. ,  175. ,
         180. ,  185. ,  190. ,  195. ,  200. ,  205. ,  210. ,  215. ,
         220. ,  225. ,  230. ,  235. ,  240. ,  245. ,  250. ,  255. ,
         260. ,  265. ,  270. ,  275. ,  280. ,  285. ,  290. ,  295. ,
         300. ,  305. ,  310. ,  315. ,  320. ,  325. ,  330. ,  335. ,
         340. ,  345. ,  350. ]),
 array([-173.47, -168.9 , -164.34, -159.77, -155.21, -150.65, -146.08,
        -141.51, -136.95, -132.38, -127.82, -123.25, -118.69, -114.13,
        -109.56, -104.99, -100.43,  -95.86,  -91.3 ,  -86.74,  -82.17,
         -81.26,  -80.34,  -79.43,  -78.52,  -77.6 ,  -76.69,  -75.78,
         -74.87,  -73.95,  -73.04,  -72.13,  -71.21,  -70.3 ,  -69.39,
         -68.47,  -67.56,  -66.65,  -65.74,  -64.82,  -63.91,  -63.  ,
         -62.08,  -61.17,  -60.26,  -59.34,  -58.43,  -57.52,  -56.61,
         -55.69,  -54.78,  -53.87,  -52.95,  -52.04,  -51.13,  -50.22,
         -48.39,  -46.56,  -44.74,  -42.91,  -41.08,  -39.26,  -37.43,
         -35.61,  -33.78,  -31.95,  -30.13,  -28.3 ,  -26.48,  -24.65,
         -22.82,  -21.  ,  -19.17,  -17.35,  -15.52,  -13.69,  -11.87,
         -10.04,   -8.22,   -6.39,   -4.57,   -2.74,   -0.91,    0.  ,
           0.91,    2.74,    4.57,    6.39,    8.22,   10.04,   11.87,
          13.69,   15.52,   17.35,   19.17,   21.  ,   22.82,   24.65,
          26.48,   28.3 ,   30.13,   31.95,   33.78,   35.61,   37.43,
          39.26,   41.08,   42.91,   44.74,   46.56,   48.39,   50.22,
          51.13,   52.04,   52.95,   53.87,   54.78,   55.69,   56.61,
          57.52,   58.43,   59.34,   60.26,   61.17,   62.08,   63.  ,
          63.91,   64.82,   65.74,   66.65,   67.56,   68.47,   69.39,
          70.3 ,   71.21,   72.13,   73.04,   73.95,   74.87,   75.78,
          76.69,   77.6 ,   78.52,   79.43,   80.34,   81.26,   82.17,
          86.74,   91.3 ,   95.86,  100.43,  104.99,  109.56,  114.13,
         118.69,  123.25,  127.82,  132.38,  136.95,  141.51,  146.08,
         150.65,  155.21,  159.77,  164.34,  168.9 ,  173.47]),
 array([-180.5 , -175.75, -171.  , -166.25, -161.5 , -156.75, -152.  ,
        -147.25, -142.5 , -137.75, -133.  , -128.25, -123.5 , -118.75,
        -114.  , -109.25, -104.5 ,  -99.75,  -95.  ,  -90.25,  -85.5 ,
         -84.55,  -83.6 ,  -82.65,  -81.7 ,  -80.75,  -79.8 ,  -78.85,
         -77.9 ,  -76.95,  -76.  ,  -75.05,  -74.1 ,  -73.15,  -72.2 ,
         -71.25,  -70.3 ,  -69.35,  -68.4 ,  -67.45,  -66.5 ,  -65.55,
         -64.6 ,  -63.65,  -62.7 ,  -61.75,  -60.8 ,  -59.85,  -58.9 ,
         -57.95,  -57.  ,  -56.05,  -55.1 ,  -54.15,  -53.2 ,  -52.25,
         -50.35,  -48.45,  -46.55,  -44.65,  -42.75,  -40.85,  -38.95,
         -37.05,  -35.15,  -33.25,  -31.35,  -29.45,  -27.55,  -25.65,
         -23.75,  -21.85,  -19.95,  -18.05,  -16.15,  -14.25,  -12.35,
         -10.45,   -8.55,   -6.65,   -4.75,   -2.85,   -0.95,    0.  ,
           0.95,    2.85,    4.75,    6.65,    8.55,   10.45,   12.35,
          14.25,   16.15,   18.05,   19.95,   21.85,   23.75,   25.65,
          27.55,   29.45,   31.35,   33.25,   35.15,   37.05,   38.95,
          40.85,   42.75,   44.65,   46.55,   48.45,   50.35,   52.25,
          53.2 ,   54.15,   55.1 ,   56.05,   57.  ,   57.95,   58.9 ,
          59.85,   60.8 ,   61.75,   62.7 ,   63.65,   64.6 ,   65.55,
          66.5 ,   67.45,   68.4 ,   69.35,   70.3 ,   71.25,   72.2 ,
          73.15,   74.1 ,   75.05,   76.  ,   76.95,   77.9 ,   78.85,
          79.8 ,   80.75,   81.7 ,   82.65,   83.6 ,   84.55,   85.5 ,
          90.25,   95.  ,   99.75,  104.5 ,  109.25,  114.  ,  118.75,
         123.5 ,  128.25,  133.  ,  137.75,  142.5 ,  147.25,  152.  ,
         156.75,  161.5 ,  166.25,  171.  ,  175.75,  180.5 ]),
 array([-190., -185., -180., -175., -170., -165., -160., -155., -150.,
        -145., -140., -135., -130., -125., -120., -115., -110., -105.,
        -100.,  -95.,  -90.,  -89.,  -88.,  -87.,  -86.,  -85.,  -84.,
         -83.,  -82.,  -81.,  -80.,  -79.,  -78.,  -77.,  -76.,  -75.,
         -74.,  -73.,  -72.,  -71.,  -70.,  -69.,  -68.,  -67.,  -66.,
         -65.,  -64.,  -63.,  -62.,  -61.,  -60.,  -59.,  -58.,  -57.,
         -56.,  -55.,  -53.,  -51.,  -49.,  -47.,  -45.,  -43.,  -41.,
         -39.,  -37.,  -35.,  -33.,  -31.,  -29.,  -27.,  -25.,  -23.,
         -21.,  -19.,  -17.,  -15.,  -13.,  -11.,   -9.,   -7.,   -5.,
          -3.,   -1.,    0.,    1.,    3.,    5.,    7.,    9.,   11.,
          13.,   15.,   17.,   19.,   21.,   23.,   25.,   27.,   29.,
          31.,   33.,   35.,   37.,   39.,   41.,   43.,   45.,   47.,
          49.,   51.,   53.,   55.,   56.,   57.,   58.,   59.,   60.,
          61.,   62.,   63.,   64.,   65.,   66.,   67.,   68.,   69.,
          70.,   71.,   72.,   73.,   74.,   75.,   76.,   77.,   78.,
          79.,   80.,   81.,   82.,   83.,   84.,   85.,   86.,   87.,
          88.,   89.,   90.,   95.,  100.,  105.,  110.,  115.,  120.,
         125.,  130.,  135.,  140.,  145.,  150.,  155.,  160.,  165.,
         170.,  175.,  180.,  185.,  190.]),
 array([-209. , -203.5, -198. , -192.5, -187. , -181.5, -176. , -170.5,
        -165. , -159.5, -154. , -148.5, -143. , -137.5, -132. , -126.5,
        -121. , -115.5, -110. , -104.5,  -99. ,  -97.9,  -96.8,  -95.7,
         -94.6,  -93.5,  -92.4,  -91.3,  -90.2,  -89.1,  -88. ,  -86.9,
         -85.8,  -84.7,  -83.6,  -82.5,  -81.4,  -80.3,  -79.2,  -78.1,
         -77. ,  -75.9,  -74.8,  -73.7,  -72.6,  -71.5,  -70.4,  -69.3,
         -68.2,  -67.1,  -66. ,  -64.9,  -63.8,  -62.7,  -61.6,  -60.5,
         -58.3,  -56.1,  -53.9,  -51.7,  -49.5,  -47.3,  -45.1,  -42.9,
         -40.7,  -38.5,  -36.3,  -34.1,  -31.9,  -29.7,  -27.5,  -25.3,
         -23.1,  -20.9,  -18.7,  -16.5,  -14.3,  -12.1,   -9.9,   -7.7,
          -5.5,   -3.3,   -1.1,    0. ,    1.1,    3.3,    5.5,    7.7,
           9.9,   12.1,   14.3,   16.5,   18.7,   20.9,   23.1,   25.3,
          27.5,   29.7,   31.9,   34.1,   36.3,   38.5,   40.7,   42.9,
          45.1,   47.3,   49.5,   51.7,   53.9,   56.1,   58.3,   60.5,
          61.6,   62.7,   63.8,   64.9,   66. ,   67.1,   68.2,   69.3,
          70.4,   71.5,   72.6,   73.7,   74.8,   75.9,   77. ,   78.1,
          79.2,   80.3,   81.4,   82.5,   83.6,   84.7,   85.8,   86.9,
          88. ,   89.1,   90.2,   91.3,   92.4,   93.5,   94.6,   95.7,
          96.8,   97.9,   99. ,  104.5,  110. ,  115.5,  121. ,  126.5,
         132. ,  137.5,  143. ,  148.5,  154. ,  159.5,  165. ,  170.5,
         176. ,  181.5,  187. ,  192.5,  198. ,  203.5,  209. ])]

In [10]:
distance[3]


Out[10]:
array([-209. , -203.5, -198. , -192.5, -187. , -181.5, -176. , -170.5,
       -165. , -159.5, -154. , -148.5, -143. , -137.5, -132. , -126.5,
       -121. , -115.5, -110. , -104.5,  -99. ,  -97.9,  -96.8,  -95.7,
        -94.6,  -93.5,  -92.4,  -91.3,  -90.2,  -89.1,  -88. ,  -86.9,
        -85.8,  -84.7,  -83.6,  -82.5,  -81.4,  -80.3,  -79.2,  -78.1,
        -77. ,  -75.9,  -74.8,  -73.7,  -72.6,  -71.5,  -70.4,  -69.3,
        -68.2,  -67.1,  -66. ,  -64.9,  -63.8,  -62.7,  -61.6,  -60.5,
        -58.3,  -56.1,  -53.9,  -51.7,  -49.5,  -47.3,  -45.1,  -42.9,
        -40.7,  -38.5,  -36.3,  -34.1,  -31.9,  -29.7,  -27.5,  -25.3,
        -23.1,  -20.9,  -18.7,  -16.5,  -14.3,  -12.1,   -9.9,   -7.7,
         -5.5,   -3.3,   -1.1,    0. ,    1.1,    3.3,    5.5,    7.7,
          9.9,   12.1,   14.3,   16.5,   18.7,   20.9,   23.1,   25.3,
         27.5,   29.7,   31.9,   34.1,   36.3,   38.5,   40.7,   42.9,
         45.1,   47.3,   49.5,   51.7,   53.9,   56.1,   58.3,   60.5,
         61.6,   62.7,   63.8,   64.9,   66. ,   67.1,   68.2,   69.3,
         70.4,   71.5,   72.6,   73.7,   74.8,   75.9,   77. ,   78.1,
         79.2,   80.3,   81.4,   82.5,   83.6,   84.7,   85.8,   86.9,
         88. ,   89.1,   90.2,   91.3,   92.4,   93.5,   94.6,   95.7,
         96.8,   97.9,   99. ,  104.5,  110. ,  115.5,  121. ,  126.5,
        132. ,  137.5,  143. ,  148.5,  154. ,  159.5,  165. ,  170.5,
        176. ,  181.5,  187. ,  192.5,  198. ,  203.5,  209. ])

In [11]:
relative_dose[3]


Out[11]:
array([  0.83378401,   0.85903316,   0.91084263,   0.96306417,
         1.04147141,   1.13276546,   1.22390966,   1.34131448,
         1.47246773,   1.63036859,   1.81430531,   2.02367849,
         2.27174955,   2.53158357,   2.81561783,   3.1522857 ,
         3.53019885,   3.93534663,   4.39013109,   4.9093496 ,
         5.46865208,   5.5802878 ,   5.69941586,   5.85413249,
         6.00997296,   6.13921566,   6.3055454 ,   6.51083526,
         6.7314844 ,   7.00795139,   7.36645941,   7.80401152,
         8.44872656,   9.57444923,  11.53818907,  14.41149784,
        17.42079241,  19.61829297,  20.89423686,  21.61275136,
        22.09937823,  22.54367344,  22.91079763,  23.26406102,
        23.63605523,  23.93499922,  24.21221545,  24.52052485,
        24.82920887,  25.10605049,  25.36753283,  25.6117828 ,
        25.86802051,  26.19693382,  26.55581645,  26.8446458 ,
        27.31029414,  27.82127109,  28.38431973,  28.96872151,
        29.56136486,  30.15513206,  30.70619297,  31.18682597,
        31.70979065,  32.2844524 ,  32.832891  ,  33.41204815,
        34.04290239,  34.60632564,  35.10793718,  35.63464801,
        36.19544896,  36.74650987,  37.26460453,  37.82877702,
        38.37946332,  38.89268796,  39.44712042,  40.03152221,
        40.63840098,  41.23404126,  41.80345838,  42.09940544,
        42.42532182,  43.02470827,  43.5716484 ,  44.18227334,
        44.81162911,  45.46720803,  46.0965638 ,  46.74090423,
        47.46016796,  48.13447771,  48.73761032,  49.32575827,
        49.93638321,  50.56199281,  51.12766377,  51.6746039 ,
        52.30770584,  52.98950792,  53.67505616,  54.29317344,
        54.86633672,  55.45823084,  55.97520165,  56.40975682,
        56.92672763,  57.49989092,  57.93069992,  58.22290082,
        58.36900126,  58.57504035,  58.75860245,  58.91968756,
        59.14445748,  59.30928875,  59.34300424,  59.43665837,
        59.56028182,  59.6277128 ,  59.74384392,  59.75882858,
        59.64269746,  59.50783551,  59.17817296,  58.51884787,
        57.18521303,  54.10211901,  47.51261427,  37.29195154,
        27.03719869,  20.08244285,  16.19692021,  13.93198868,
        12.49495968,  11.50784513,  10.75449129,  10.15697793,
         9.71567966,   9.37627708,   9.05148455,   8.71770123,
         8.4202557 ,   8.20747352,   8.0167937 ,   7.00532908,
         6.16131804,   5.44767355,   4.83967093,   4.33543708,
         3.90874886,   3.53192209,   3.18068163,   2.88297388,
         2.65003732,   2.42826434,   2.20514273,   2.03664022,
         1.9089709 ,   1.77920374,   1.64786318,   1.53075806,
         1.4410374 ,   1.35101705,   1.24691111])

In [12]:
plt.plot(distance[3], relative_dose[3])


Out[12]:
[<matplotlib.lines.Line2D at 0xaa25940>]

In [13]:
plt.plot(distance[0], relative_dose[0])
plt.plot(distance[1], relative_dose[1])

plt.legend([scan_depth[0], scan_depth[1]])


Out[13]:
<matplotlib.legend.Legend at 0xacbdef0>

Using interpolation

Find D10


In [21]:
# Example of using the interpolation function
# Find D10 of a PDD

# Find the index of where the scan curvetype equals PDD
index = np.where(scan_curvetype == 'PDD')[0][0]
index


Out[21]:
4

In [22]:
plt.plot(distance[index], relative_dose[index])


Out[22]:
[<matplotlib.lines.Line2D at 0xb0172e8>]

In [23]:
# Interpolate the dose given the distance
interplolation = interp1d(distance[index], relative_dose[index])
interplolation(100)


Out[23]:
array(68.99950209413349)

Find R50


In [17]:
# Find R50 of a PDD
# The interpolation is only robust if only the points after dmax are chosen 
# This is so that the PDD can be inverted and be one-to-one

# Find dmax
dmax_index = np.argmax(relative_dose[index])
dmax_index


Out[17]:
15

In [18]:
dmax = distance[index][dmax_index]
dmax


Out[18]:
15.0

In [19]:
distance_subset = distance[index][dmax_index:]
relative_dose_subset = relative_dose[index][dmax_index:]
plt.plot(distance_subset, relative_dose_subset)


Out[19]:
[<matplotlib.lines.Line2D at 0xadae5c0>]

In [20]:
# Interpolate distance given dose
interplolation = interp1d(relative_dose_subset, distance_subset)
interplolation(50)


Out[20]:
array(165.41514041514043)

Redistribute dose points


In [34]:
# Define new grid
new_distance = np.arange(0, 100, 0.75)

interplolation = interp1d(distance[index], relative_dose[index])
new_relative_dose = interplolation(new_distance)

In [37]:
plt.scatter(new_distance, new_relative_dose, color='red', alpha=0.5)
plt.scatter(distance[index], relative_dose[index], alpha=0.5)


plt.xlim([0, 120])


Out[37]:
(0, 120)